# Copyright (c) 2006, Creator of the Cant Project.
# All rights reserved.
# 
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 
# + Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# 
# + Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# 
# + Neither the name of the Creator of the Cant Project nor the names of its
# contributors may be used to endorse or promote products derived from this
# software without specific prior written permission.
# 
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

CC=g++

CFLAGS=-c -Wall
LDFLAGS=

SOURCE_BASE=base/exception.cpp
SOURCE_UTIL=util/log.cpp util/util.cpp util/stringiter.cpp
SOURCE_TINY=project/tiny/tinystr.cpp project/tiny/tinyxmlerror.cpp project/tiny/tinyxmlparser.cpp project/tiny/tinyxml.cpp
SOURCE_PROJECT=project/except.cpp project/project.cpp project/projlist.cpp project/projtag.cpp project/depend.cpp
SOURCE_TAGS=project/tags/basictag.cpp project/tags/filetag.cpp

SOURCE_MAIN=main.cpp
BIN_SOURCES=$(SOURCE_MAIN) $(SOURCE_BASE) $(SOURCE_UTIL) $(SOURCE_TINY) $(SOURCE_PROJECT) $(SOURCE_TAGS)

SOURCE_TEST=test/maintest.cpp test/testcase.cpp test/testsuite.cpp
SOURCE_TESTCASE=test/unit/projecttest.cpp
TEST_SOURCES=$(SOURCE_TEST) $(SOURCE_TESTCASE) $(SOURCE_BASE) $(SOURCE_UTIL) $(SOURCE_TINY) $(SOURCE_PROJECT) $(SOURCE_TAGS)


##############################################################################


BIN_OBJECTS=$(BIN_SOURCES:.cpp=.o)
TEST_OBJECTS=$(TEST_SOURCES:.cpp=.o)

BIN_EXECUTABLE=cant
TEST_EXECUTABLE=testcant

all: $(BIN_SOURCES) $(BIN_EXECUTABLE)

test: $(TEST_SOURCES) $(TEST_EXECUTABLE)
	./testcant

$(BIN_EXECUTABLE): $(BIN_OBJECTS) 
	$(CC) $(LDFLAGS) $(BIN_OBJECTS) -o $@

$(TEST_EXECUTABLE): $(TEST_OBJECTS) 
	$(CC) $(LDFLAGS) $(TEST_OBJECTS) -o $@

.cpp.o:
	$(CC) $(CFLAGS) $< -o $@

clean:
	rm -f *.o
	rm -f base/*.o
	rm -f util/*.o
	rm -f project/tiny/*.o
	rm -f project/*.o
	rm -f project/tags/*.o
	rm -f test/*.o
	rm -f test/unit/*.o
	rm -f $(TEST_EXECUTABLE)
	
cleanall:	clean
	rm -f $(BIN_EXECUTABLE)
